import { defHttp } from '/@/utils/http/axios';
import {
  WebsiteExpertModel,
  WebsiteExpertTableRecordModel,
} from '../model/websiteExpertModel';
import { ErrorMessageMode } from '/#/axios';

enum Api {
  WEBSITEEXPERT_PAGE = '/jxxhWebsite/websiteExpert/getExpertVosPage',
  GET_EXPERT_LIST = '/jxxhWebsite/websiteExpert/getExpertList',
  GET_WEBSITEEXPERTVO_BY_ID = '/jxxhWebsite/websiteExpert/',
  WEBSITEEXPERTVO_SAVE = '/jxxhWebsite/websiteExpert/save',
  WEBSITEEXPERTVO_UPDATE = '/jxxhWebsite/websiteExpert/updateById',
  WEBSITEEXPERTVO_REMOVE = '/jxxhWebsite/websiteExpert/logicalRemoveById/',
}

/**
 * @description: Get sample list value
 */

export const websiteExpertListApi = (params: Object) =>
  defHttp.get<WebsiteExpertTableRecordModel>(
    { url: Api.GET_EXPERT_LIST, params },
    { errorMessageMode: 'message' },
  );

export const getExpertListApi = (params: Object) =>
  defHttp.get<WebsiteExpertTableRecordModel>(
    { url: Api.WEBSITEEXPERT_PAGE, params },
    { errorMessageMode: 'message' },
  );

export const getWebsiteExpertVoByIdApi = (id) =>
  defHttp.get<WebsiteExpertModel>(
    { url: Api.GET_WEBSITEEXPERTVO_BY_ID + id },
    { errorMessageMode: 'message' },
  );

export function websiteExpertSaveApi(
  params: WebsiteExpertModel,
  mode: ErrorMessageMode = 'modal',
) {
  return defHttp.post<WebsiteExpertModel>(
    {
      url: Api.WEBSITEEXPERTVO_SAVE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function websiteExpertUpdateApi(
  params: WebsiteExpertModel,
  mode: ErrorMessageMode = 'modal',
) {
  return defHttp.put<WebsiteExpertModel>(
    {
      url: Api.WEBSITEEXPERTVO_UPDATE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export const logicalRemoveById = (id) =>
  defHttp.delete<WebsiteExpertModel>(
    { url: Api.WEBSITEEXPERTVO_REMOVE + id },
    { errorMessageMode: 'message' },
  );
